package com.koron.css2.newProjectCenter.impl.query.statistics;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.impl.query.statistics.bean.PjStatInstallApplyBean;
import com.koron.css2.newProjectCenter.impl.query.statistics.bean.PjStatStatusBean;
import com.koron.css2.newProjectCenter.impl.query.statistics.vo.PjStatInstallApplyVo;
import com.koron.css2.newProjectCenter.impl.query.statistics.vo.PjStatInstallApplyVoDetail;
import com.koron.css2.newProjectCenter.impl.query.statistics.vo.PjStatStatusVo;
import com.koron.css2.newProjectCenter.impl.query.statistics.vo.PjStatStatusVoDetail;
import com.koron.css2.newProjectCenter.mapper.PjStatInstallApplyMapper;
import com.koron.css2.newProjectCenter.mapper.PjStatStatusMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

/**
 * 报装申请统计
 */
public class PjStatStatusApply implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        PjStatStatusBean bean = JsonUtils.objectToPojo(req.getData(), PjStatStatusBean.class);
        PjStatStatusMapper mapper = factory.getMapper(PjStatStatusMapper.class);

        if (bean.getBusinessArea() == null) {
            return MessageBean.create(Constant.ILLEGAL_PARAMETER, "参数错误", null);
        }

        List<PjStatStatusVoDetail> list = mapper.getList(bean);
        PjStatStatusVo vo = new PjStatStatusVo();
        vo.setList(list);

        MessageBean result = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查询成功", PjStatInstallApplyVo.class);
        result.setData(vo);
        return result;
    }
}
